//
//  FeedbackView.swift
//  Kosspot
//
//  Created by 李鑫 on 2025/7/1.
//

import SwiftUI

struct FeedbackView: View {
    @EnvironmentObject var appState: AppState
    @State private var problemDescription = ""
    @State private var attachment = UIImage() // 附件，虽然未直接使用，但保留接口
    @State private var appearanceFrequency = "很少出现"
    @State private var contactMethod = ""
    @State private var problemOccurredDate = Date()
    

    var body: some View {
        ScrollView{
            ZStack {
                VStack {
                    Spacer().frame(height: NavigationBarHeightHelper.getTotalHeight()+12)
                    HStack {
                        Text("问题与建议").font(.system(size: 16)).foregroundColor(.white)+Text("*").font(.system(size: 16)).foregroundColor(.red)
                        Spacer()
                    }.padding(12)
                    Spacer().frame(height: 12)
                    VStack {
                        ZStack(alignment: .topLeading) {
                            TextEditor(text:$problemDescription)
                                .scrollContentBackground(.hidden)
                                .frame(height: 160)
                                .foregroundColor(.primary)
                                .background(.clear)
                                .padding(12)
                            
                            if problemDescription.isEmpty {
                                Text("请详细描述问题，谢谢您的支持")
                                    .font(.system(size: 14))
                                    .foregroundStyle(Color(hex: "#B2B2B2"))
                                    .padding(12)
                            }
                        }
                        
                        ScrollView(.horizontal){
                            Button(action: {
                                //照片
                            }) {
                            }
                            .background(
                                Image("paizhao")  // 使用Assets中的图片
                                    .resizable()
                                    .aspectRatio(contentMode: .fill)
                                    .frame(width: 64,height: 64)
                                    .cornerRadius(10)
                            )
                            
                            
                        }.padding(16)
                            .frame(height: 70)
                            
                            
                        
                        
                        
                    }
                    .gradientBackground(colors: [Color(hex: "#242424")], cornerRadius: 8)
                    .padding(.horizontal,12)
                    .frame(height: 230)
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                  Spacer()
                    
                    
                    
                    HStack {
                        Button {
                            
                        } label: {
                            Text("提交")
                                .font(.system(size: 16))
                                .foregroundStyle(Color(hex: "#242424"))
                        }
                    }
                    .frame(maxWidth: .infinity, alignment: .center)
                    .frame(height: 44)
                    .gradientBackground(colors: [Color(hex: "#00F3AF"),Color(hex: "#00E9DA")], type: .linear(start: .leading, end: .trailing), cornerRadius: 22.0)
                    .padding(.horizontal,12)
                    .padding(.bottom,20)
                    
                    
                }.frame(minHeight: UIScreen.main.bounds.height)
            }
        }
        .ignoresSafeArea()
        .background(Color(hex: "#0A0A0"))
        .customNavigationBar(title: "意见反馈", backButtonAction: {
            appState.navigateBack()
        }, backgroundColor: UIColor(Color(hex: "#0A0A0")))
    }
}

#Preview {
    FeedbackView()
}
